package com.xcity.game.combat.impl;

import com.xcity.game.combat.Combat;
import com.xcity.game.combat.CombatTeam;
import com.xcity.game.combat.listener.CombatListener;

import naga.x.game.time.TimeUpdater;

/**
 * 有限时的战斗
 * @author yang.li
 *
 */
public class TimeLimitedCombat extends Combat {
	
	private long timestamp; // 限时战斗结束时间

	public TimeLimitedCombat(CombatTeam source, CombatTeam target, Type type, CombatListener listener) {
		this(source, target, type, listener, -1L);
	}
	
	public TimeLimitedCombat(CombatTeam source, CombatTeam target, Type type, CombatListener listener, long timeout) {
		super(source, target, type, listener);
		setTimeout(timeout);
	}

	public void setTimeout(long timeout) {
		this.timestamp = timeout > 0 ? TimeUpdater.getInstance().now() + timeout : -1;
	}

	@Override
	public boolean isTimeout() {
		return timestamp < TimeUpdater.getInstance().now();
	}
	

}
